import 'package:flutter/material.dart';
import 'package:yysk_app/utils/colors.dart';
import 'package:yysk_app/utils/helper.dart';

enum ImageWidgetType { asset, network }

class ImageAssetWidget extends StatelessWidget {
  final String imageUrl;
  final BorderRadius radius;
  final double? width;
  final double? height;
  final ImageWidgetType? type;
  final BoxFit fit;
  final AlignmentGeometry alignment;
  final VoidCallback? onPressed;
  const ImageAssetWidget({
    super.key,
    required this.imageUrl,
    this.radius = BorderRadius.zero,
    this.width = 10,
    this.height = 10,
    this.type = ImageWidgetType.asset,
    this.fit = BoxFit.cover,
    this.alignment = Alignment.center,
    this.onPressed,
  });

  @override
  Widget build(BuildContext context) {
    return imageUrl.isEmpty
        ? SizedBox(width: width, height: height)
        : PhysicalModel(
          color: Colors.transparent,
          clipBehavior: Clip.antiAlias,
          borderRadius: radius,
          child: SizedBox(
            // color: AppColors.startColor,
            width: width,
            height: height,
            child: Image.asset(
              imageUrl,
              width: width,
              height: height,
              fit: fit,
              alignment: alignment,
              cacheWidth:
                  (width != null && (width?.isFinite ?? false))
                      ? (width! * MediaQuery.of(context).devicePixelRatio)
                          .ceil()
                      : null,
              cacheHeight:
                  (height != null && (height?.isFinite ?? false))
                      ? (height! * MediaQuery.of(context).devicePixelRatio)
                          .ceil()
                      : null,
            ),
          ),
        );
  }
}
